package com.itheima.service.impl;

import com.itheima.dao.AddressDao;
import com.itheima.entity.Address;
import com.itheima.entity.PageBean;
import com.itheima.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    private AddressDao addressDao;
    /**
     * 通过aid查询一个地址
     *
     * @param aid
     */
    @Override
    public Address findByAid(int aid) {
        return null;
    }

    /**
     * 通过uid查询某个用户1页的地址
     *
     * @param current 第几页
     * @param size    每页大小
     * @param uid     用户id
     */
    @Override
    public PageBean<Address> findAddress(int current, int size, int uid) {
        int begin = (current - 1 ) * size;
        List<Address> data = addressDao.findByUid(uid, begin, size);
        int count = addressDao.findCount(uid);
        return new PageBean<>(data,count,current,size);
    }

    /**
     * 保存地址
     *
     * @param address
     */
    @Override
    public void save(Address address) {

    }

    /**
     * 更新地址信息
     *
     * @param address
     */
    @Override
    public void update(Address address) {

    }

    /**
     * 删除
     *
     * @param aid
     */
    @Override
    public void delete(Integer aid) {

    }

    /**
     * 设置默认地址
     *
     * @param uid 用户id
     * @param aid 地址id
     */
    @Override
    public void changeDefaultAddress(Integer uid, Integer aid) {

    }
}
